<?php
	class phanlopdb
	{
		public function Add($MaPhanLop,$MaLop,$MaGiaoVien,$SiSo,$NamHoc)
		{
			$sql = " INSERT INTO `tbl_phanlop`(`MaPhanLop`, `MaLop`, `MaGiaoVien`, `SiSo`, `NamHoc`) VALUES ('$MaPhanLop',$MaLop,'$MaGiaoVien',$SiSo,'$NamHoc')";
			$data = new dataservice();
			return $data->ExecuteNonQuery($sql);
		}
		
		public function Delete($MaPhanLop)
		{
			$sql = "DELETE FROM `tbl_phanlop` WHERE MaPhanLop = '$MaPhanLop' ";
			$data = new dataservice();
			return $data->ExecuteNonQuery($sql);
		}
		
		public function Update($MaPhanLop,$MaLop,$MaGiaoVien,$SiSo,$NamHoc)
		{
			$sql = " UPDATE `tbl_phanlop`
			 SET NamHoc = '$NamHoc',
			 	 SiSo = $SiSo,
				 MaGiaoVien = '$MaGiaoVien'
			 WHERE MaPhanLop = '$MaPhanLop' "; 
			$data = new dataservice();
			return $data->ExecuteNonQuery($sql);
		}
	
	
		public function GetList($MaPhanLop,$MaLop,$MaGiaoVien,$SiSo,$NamHoc)
		{
			$sql = " SELECT * FROM `tbl_phanlop`,`tbl_lop`,`tbl_giaovien` WHERE tbl_phanlop.MaLop = tbl_lop.MaLop AND tbl_giaovien.MaGiaoVien = tbl_phanlop.MaGiaoVien ";
			if($MaPhanLop!="")
				$sql .= " AND tbl_phanlop.MaPhanLop = '$MaPhanLop' ";
			if($MaLop!="")
				$sql .= " AND tbl_phanlop.MaLop = '$MaLop' ";
			if($MaGiaoVien!="")
				$sql .= " AND tbl_phanlop.MaGiaoVien = '$MaGiaoVien' ";
			if($SiSo!="")
				$sql .= " AND tbl_phanlop.SiSo = $SiSo ";
			if($NamHoc!="")
				$sql .= " AND tbl_phanlop.NamHoc = '$NamHoc' ";
			$data = new dataservice();
			return $data->ExecuteQuery($sql);
		}
		
		
		
	}
?>